package com.woniuxy.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.entity.Procurement;

@Mapper
public interface ProcurementMapper {
	@Select("select * from t_procurement")
	public List<Procurement> findProcurement();
	
	@Select("select * from t_procurement where orderno=#{orderno}")
	public Procurement findProcurementByOrderno(String orderno);
	
	//插入一条数据
	@Insert("insert into t_procurement values(default,#{orderno},#{supplier},#{prodepartment},"
			+ "#{weight},#{num},#{name},#{time},#{status},#{category},#{line},#{storehouse},#{quality},#{formtype})")
	public int insertProcurement(Procurement procurement);
	
	//编辑分配单
	@Update("update t_procurement set category=#{category},storehouse=#{storehouse},quality=#{quality},time=#{time},line=#{line} where orderno=#{orderno}")
	public int updateProcurementByOrderno(Procurement procurement);
	
	//删除分配单
	@Delete("delete from t_procurement where orderno=#{orderno}")
	public int delProcurementByOrderno(String orderno);
	
	//完成后修改状态
	@Update("update t_procurement set status=#{status} where orderno=#{orderno}")
	public int changeStatus(Procurement procurement);
	@Update("update t_demand set status=#{status} where orderno=#{orderno}")
	public int changeStatusbyor(Procurement procurement);
	@Update("update t_distribution_requirements set status=#{status} where orderno=#{orderno}")
	public int changeStatusbyno(Procurement procurement);
}
